#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int n = 0;
	int a = 0;
	scanf("%d", &n);
	scanf("%d", &a);
	n = n | (1 << a-1);
	printf("%d\n", n);
	n = n & ~(1 << (a - 1));
	printf("%d\n", n);
	return 0;
}